/*
 * File: E:\Kan\ARM\Projects\Google Code\Umrichter\trunk\SimulinkModelle\slprj\ert\_sharedutils\div_repeat_u32.c
 *
 * Code generated for Simulink model 'Fu_Foc'.
 *
 * Model version                  : 1.270
 * Simulink Coder version         : 8.2 (R2012a) 29-Dec-2011
 * TLC version                    : 8.2 (Dec 29 2011)
 * C/C++ source code generated on : Sun Apr 28 18:42:25 2013
 */

#include "rtwtypes.h"
#include "rtw_shared_utils.h"

uint32_T div_repeat_u32(uint32_T numerator, uint32_T denominator, uint32_T
  nRepeatSub)
{
  uint32_T quotient;
  uint32_T iRepeatSub;
  uint8_T numeratorExtraBit;
  if (denominator == 0) {
    quotient = MAX_uint32_T;

    /* Divide by zero handler */
  } else {
    quotient = numerator / denominator;
    numerator %= denominator;
    for (iRepeatSub = 0; iRepeatSub < nRepeatSub; iRepeatSub++) {
      numeratorExtraBit = (numerator >= 2147483648U);
      numerator <<= 1;
      quotient <<= 1;
      if (numeratorExtraBit || (numerator >= denominator)) {
        quotient++;
        numerator -= denominator;
      }
    }
  }

  return quotient;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
